function  [aligned_x, aligned_y] = shape_transform(x, y, rot, trans)
% (x1 y1) --- shapes;  (x2, y2)--- refshape
% x2	=	[a -b] x1  + [c]					
% y2	=	[b  a] y1   + [d]
% [a b c d] --- @transf 
% shape in @shapes mulitply parameter in@return to align @ refshape
shape_combine   =   0;
if(isempty(y))
    y   =   x(:,2:2:end);
    x   =   x(:,1:2:end);
    shape_combine = 1;
end

if(isempty(trans))
   trans =  rot(:,3:4);
   rot   =  rot(:,1:2);  
end


    num     =   size(x,2);
    aligned_x =  x.*repmat(rot(:,1), 1,  num) - y.*repmat(rot(:,2),1, num);
    aligned_x =  aligned_x + repmat(trans(:,1), 1,  num);              

    aligned_y  =   x.*repmat(rot(:,2), 1, num) + y.*repmat(rot(:,1),1, num);
    aligned_y  =   aligned_y + repmat(trans(:,2), 1, num);
    
if(shape_combine)   
    aligned_x = combine_divid_xy(aligned_x,aligned_y);
    aligned_y = [];
end    
end    
